package com.yunhe.mybatis.web.deparment;

import com.yunhe.mybatis.entity.Deparment;
import com.yunhe.mybatis.service.DeparmentService;
import com.yunhe.mybatis.service.impl.DeparmentServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/deparment/d/detele")
public class Delete extends HttpServlet {

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        //从list页面中拿的数据 带入到
        Integer parameter = Integer.valueOf(req.getParameter("deparmentId"));

        DeparmentService deparmentService = new DeparmentServiceImpl();

        deparmentService.remove(parameter);

        req.getRequestDispatcher("/success.jsp").forward(req,resp);
    }

}
